
package tolls;

import avenue.MyWindowEvent;
import avenue.Session;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import model.Card;
import model.Collection;
import model.DBManager;
import model.ProgramRate;
import model.Vehicle;

/**
 *
 * @author Team-2
 */
public class CollectTollForm extends javax.swing.JFrame {
    
    private final EntityManager em;
    private Card c;
    private BigDecimal rate;
    JFrame thisFrame;
    

    /**
     * Creates new form CollectTollForm
     */
    public CollectTollForm() {
        
        em = DBManager.em;
        if ( !em.getTransaction().isActive()){
            em.getTransaction().begin();
        }
        
        initComponents();
        
        transitButton.setEnabled(false);
        payButton.setEnabled(false);
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        regNumText = new javax.swing.JTextField();
        transitButton = new javax.swing.JButton();
        cardNumText = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        payButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        balanceCardText = new javax.swing.JTextField();
        checkCardImage = new javax.swing.JLabel();
        checkRegImage = new javax.swing.JLabel();
        cancelButton = new javax.swing.JButton();
        infoLabel = new javax.swing.JLabel();
        countPassesLabel = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Διέλευση Οχήματος");
        setResizable(false);

        regNumText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                regNumTextKeyReleased(evt);
            }
        });

        transitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/transit.png"))); // NOI18N
        transitButton.setText("Διέλευση");
        transitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transitButtonActionPerformed(evt);
            }
        });

        cardNumText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                cardNumTextKeyReleased(evt);
            }
        });

        jLabel2.setText("Αρ. Κάρτας (Barcode): ");

        jLabel1.setText("Αρ. Κυκλοφορίας: ");

        payButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pay.png"))); // NOI18N
        payButton.setText("Πληρωμή");
        payButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                payButtonActionPerformed(evt);
            }
        });

        jLabel3.setText("Υπόλοιπο Κάρτας: ");

        balanceCardText.setEditable(false);

        cancelButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/exit.png"))); // NOI18N
        cancelButton.setText("Κλείσιμο");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        infoLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        infoLabel.setForeground(new java.awt.Color(255, 0, 0));
        infoLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        countPassesLabel.setForeground(new java.awt.Color(0, 102, 255));
        countPassesLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jSeparator2)
                        .addGap(14, 14, 14))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jSeparator3)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(cancelButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(payButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(transitButton)
                        .addGap(0, 10, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jLabel2))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cardNumText, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(regNumText, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(balanceCardText, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(checkRegImage, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(checkCardImage, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(26, 26, 26))
                            .addComponent(countPassesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
                            .addComponent(infoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(regNumText)
                            .addComponent(checkRegImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cardNumText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addComponent(checkCardImage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(balanceCardText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(countPassesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(infoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(transitButton)
                    .addComponent(cancelButton)
                    .addComponent(payButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void cardNumTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cardNumTextKeyReleased
     
      String sCardNum = this.cardNumText.getText();
      Integer cardNum = 0; 

      infoLabel.setText("");

        if (!sCardNum.isEmpty()) {   
           cardNum = Integer.parseInt(sCardNum);
        }  
              
        try {   
             c = 
             em.createNamedQuery("Card.findByBarcode",
                                 Card.class)
                                 .setParameter("barcode", cardNum)
                                 .getSingleResult();                           
               if (c!=null) { //correct cardId number
                 checkCardImage.setIcon(new ImageIcon(Session.imgPath + "check.png")); 
                 checkCardAndRegNumber();                            
               } else { //not correct card id
                        checkCardImage.setIcon(null);
                        countPassesLabel.setText(null);
               }  
        } catch (NoResultException ex) {         
                 checkCardImage.setIcon(null);
                 transitButton.setEnabled(false); 
                 payButton.setEnabled(false);
                 balanceCardText.setText(null);
                 countPassesLabel.setText(null);
        } catch (PersistenceException ex) {
                   System.out.println("Παρουσιάστηκε σφάλμα: " + ex);            
        }  
 
    }//GEN-LAST:event_cardNumTextKeyReleased

    
    private void regNumTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_regNumTextKeyReleased
      
      String regNumber = this.regNumText.getText();
      infoLabel.setText(null);
        
        if ( !regNumber.isEmpty() ) {
         
            try {   
                 //find vehicle with this reg number
                 Vehicle v = 
                 em.createNamedQuery("Vehicle.findByRegNumber",
                                     Vehicle.class)
                                    .setParameter("regNumber", regNumber)
                                    .getSingleResult();                           
                if (v!=null) { //correct cardId number
                   checkRegImage.setIcon(new ImageIcon(Session.imgPath + "check.png")); 
                   checkCardAndRegNumber();
                } else {
                    checkRegImage.setIcon(null);
                    transitButton.setEnabled(false); 
                    payButton.setEnabled(false);
                    balanceCardText.setText(null);
                    countPassesLabel.setText(null);
                }
            } catch (NoResultException ex) {
                       checkRegImage.setIcon(null);   
                       transitButton.setEnabled(false); 
                       balanceCardText.setText(null);
                       countPassesLabel.setText(null);
            } catch (PersistenceException ex) {
                       System.out.println("Παρουσιάστηκε σφάλμα: " + ex);            
            } 
        } else {
            checkRegImage.setIcon(null); 
        }    
        
    }//GEN-LAST:event_regNumTextKeyReleased

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void transitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transitButtonActionPerformed
      
       insertNewCollection();
       dispose();
       
    }//GEN-LAST:event_transitButtonActionPerformed

    
    private void payButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_payButtonActionPerformed
      
        final PaymentForm pf =  new PaymentForm(c);
        pf.setIconImage(Toolkit.getDefaultToolkit().getImage(Session.imgPath + "paymentIcon.png"));
        pf.setVisible(true);
        pf.setLocationRelativeTo(null); //center form
        thisFrame=this;
        thisFrame.setEnabled(false);

///////////////////////////Start Listeners//////////////////////////////////////
        pf.addWindowListener(new WindowListener() {
            public void windowClosed(WindowEvent arg0) {
                System.out.println("Window close event occur");
                if (((MyWindowEvent) arg0).exitAndSave) {  
                   String newBalance = pf.newBalance; 
                    balanceCardText.setText(newBalance);
                    setInfoMessage(Double.parseDouble(newBalance));
                    thisFrame.setEnabled(true);
                }else {
                     thisFrame.setEnabled(true);
                }   
            }

              public void windowActivated(WindowEvent arg0) {
                System.out.println("Window Activated");
            }

            public void windowClosing(WindowEvent arg0) {
                System.out.println("Window Closing");
            }

            public void windowDeactivated(WindowEvent arg0) {
                System.out.println("Window Deactivated");
            }

            public void windowDeiconified(WindowEvent arg0) {
                System.out.println("Window Deiconified");
            }

            public void windowIconified(WindowEvent arg0) {
                System.out.println("Window Iconified");
            }

            public void windowOpened(WindowEvent arg0) {
                System.out.println("Window Opened");
            }
        });                
    }//GEN-LAST:event_payButtonActionPerformed

    
    /**
    * Check if this card is associated with the Reg Number
    */
    private void checkCardAndRegNumber() {
        
      String regNumber = this.regNumText.getText();
      String sCardNum = this.cardNumText.getText();
    
          try {   
                Vehicle vc = 
                em.createNamedQuery("Vehicle.hasVehicleThisCard",
                                   Vehicle.class)
                                   .setParameter("regNumber", regNumber)
                                   .setParameter("cardId", c)
                                    .getSingleResult();     
                 //validate card and reg number                       
                  if (vc!=null) {
                     Double balance = vc.getCardId().getBalance();
                     balanceCardText.setText(String.valueOf(balance));
                     //enable button for transit
                     transitButton.setEnabled(true);  
                        if ( hasBonusTransit() ) { //if has bonus pass
                                rate = new BigDecimal(0); //free pass
                        } else {
                           rate = getRate(); // get rate of current pass
                        }   
                     //if user has permition for payment
                     if (Session.doesSessionUserHasPermission(Session.PAYMENTS_MODULE)) {   
                        payButton.setEnabled(true); 
                     }     
                     setInfoMessage(balance);                     
                  } else {
                     //disable button for transit
                     transitButton.setEnabled(false);
                     payButton.setEnabled(false);
                     balanceCardText.setText(null);
                     if (!regNumber.isEmpty() && !sCardNum.isEmpty()) {
                         infoLabel.setText("Ο αρ. κυκλοφορίας δεν αντιστοιχεί στον αρ. Κάρτας");
                     }    
                  }  
              } catch (NoResultException ex) {
                      //disable button for transit
                      transitButton.setEnabled(false);
                      payButton.setEnabled(false);
                      balanceCardText.setText(null);
                      if (!regNumber.isEmpty() && !sCardNum.isEmpty()) {  
                          infoLabel.setText("Ο αρ. κυκλοφορίας δεν αντιστοιχεί στον αρ. Κάρτας");
                      }                                
              } catch (PersistenceException ex) {
                         System.out.println("Παρουσιάστηκε σφάλμα: " + ex);            
              }                              

    }
    
    private boolean hasBonusTransit() {

       try {             
            int monthlyDemand = c.getProgramId().getMonthlyDemands();
            int bonusTransits = c.getProgramId().getBonusTransits();            
            int currentTransits = 0;
            int takenFreePasses = 0;
            List<Collection> cList = c.getCollectionList();
            
             for (Collection collection : cList) {
                //count all pay transits for this card in current month              
                if ( collection.getCardId().getId() == c.getId() && 
                     collection.getPassTimestamp().getMonth() == new Date().getMonth() ) {   
                       currentTransits++; //count passes
                       if ( collection.getTollCollected().doubleValue() == 0 ) {
                           takenFreePasses++; //free passes
                       }     
                }
             }
            //When card have make all required transits for bonus in the month 
            //and not has taken all bonus days        
            if (currentTransits >= monthlyDemand && takenFreePasses < bonusTransits) {
                 int bonusDayesLeft = bonusTransits - takenFreePasses;
                 String message = "Σύνολο διελεύσεων : " + currentTransits + 
                                  " | <Δωρεάν διέλευση> | Υπόλοιπο: " + bonusDayesLeft;
                 countPassesLabel.setText(message);
                return true;
            } else {
               String message = "Σύνολο διελεύσεων : " + currentTransits;
               countPassesLabel.setText(message);
               return false;
            }
       }catch (Exception ex) {
           System.out.println("Problem: " +ex);
           return false;
       }
    
    }    
    
    /**
     * Calculate the rate of current card for this station
     */
    private BigDecimal getRate() {
        
     BigDecimal retRate=new BigDecimal(0);
    
      try { 
            ProgramRate rate =
            em.createNamedQuery("ProgramRate.findByProgram", ProgramRate.class)
                               .setParameter("programId", c.getProgramId())
                               .setParameter("categoryId", c.getVehicle().getCategoryId())
                               .setParameter("stationId", Session.loginUser.getStationId())
                               .getSingleResult(); 
            retRate= rate.getRate();
       }catch (PersistenceException ex) {
                       System.out.println("Παρουσιάστηκε σφάλμα: " + ex);            
       } 
       
     return retRate;
    }
        
    /**
     * Create info messages
     * @param balance 
     */
    private void setInfoMessage(Double balance) {
        
      String message;    
      if ( rate!=null ) {
          
        double dRate = rate.doubleValue();

          if (balance >= dRate) {
              if (balance <= 5.0) {
                  message = "Χαμηλό υπόλοιπο κάρτας (" + balance + "\u20AC). Συστήνεται πληρωμή."; 
                  //if user has permition for payment
                  if (Session.doesSessionUserHasPermission(Session.PAYMENTS_MODULE)) {
                      payButton.setEnabled(true);
                  }
              } else {
                message = "Κόστος διέλευσης: " + Double.toString(dRate) + "\u20AC" +
                          " | Νέο υπόλοιπο: " + Double.toString(balance -  dRate) + "\u20AC"; 
                transitButton.setEnabled(true);
              }       
          } else { //balance < tollCost
                  transitButton.setEnabled(false); //disable button 
                  //if user has permition for payment
                  if (Session.doesSessionUserHasPermission(Session.PAYMENTS_MODULE)) {
                      payButton.setEnabled(true);
                  }    
                  message = "Ανεπαρκές υπόλοιπο (" + balance + "\u20ac). Απαιτείται πληρωμή.";    
          }   
      } else { //Not valid rate
          message = "Δεν υπάρχει ποσό χρέωσης στο πρόγραμμα αυτό!";
          transitButton.setEnabled(false);
      }   

      infoLabel.setText(message);
    }
    
    /**
     * Insert new transit of card and updates all involved tables
     */
    private void insertNewCollection() {
      
        Double currentBalance; 
        
        try {                   
              if ( !em.getTransaction().isActive()){
                   em.getTransaction().begin();
              }                  
         
             //insert new row in Collection
             model.Collection t = new model.Collection(c, Session.loginUser.getStationId(), new Date(), rate);             
             em.persist(t);

             // set new balance of current card
             currentBalance = Double.parseDouble(balanceCardText.getText());
             c.setBalance(currentBalance - rate.doubleValue()); 
             em.persist(c);
             em.getTransaction().commit(); 
             em.refresh(c);

        } catch (PersistenceException ex) {
            System.out.println("Παρουσιάστηκε σφάλμα: " + ex);
        }        

    }
    
    /**
     * Update balance, PaymentForm use this method for update balance after card load
     * @param newBalance 
     */
    public void updateBalance(String newBalance) {
     //  newBalanceText.getText()
        balanceCardText.setText(newBalance);
        setInfoMessage(Double.parseDouble(newBalance));
    
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CollectTollForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CollectTollForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CollectTollForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CollectTollForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CollectTollForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField balanceCardText;
    private javax.swing.JButton cancelButton;
    private javax.swing.JTextField cardNumText;
    private javax.swing.JLabel checkCardImage;
    private javax.swing.JLabel checkRegImage;
    private javax.swing.JLabel countPassesLabel;
    private javax.swing.JLabel infoLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JButton payButton;
    private javax.swing.JTextField regNumText;
    private javax.swing.JButton transitButton;
    // End of variables declaration//GEN-END:variables


}
